package cn.mijack.face.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import cn.mijack.face.DemoActivity;
import cn.mijack.face.FaceDetectActivity;
import cn.mijack.face.UploadImageActivity;

/**
 * Created by MiJack on 2016/6/7.
 */
public class ActivityAdapter extends BaseAdapter {
    Info[] infos = new Info[]{
            new Info("脸部识别", FaceDetectActivity.class),
            new Info("图片上传", UploadImageActivity.class),
            new Info("Demo", DemoActivity.class)
    };

    @Override
    public int getCount() {
        return infos.length;
    }

    @Override
    public Info getItem(int position) {
        return infos[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1, parent, false);
        }
        TextView tv = (TextView) convertView;
        tv.setText(getItem(position).label);
        return convertView;
    }

    public static class Info {
        public String label;
        public Class<? extends Activity> activity;

        public Info(String label, Class<? extends Activity> activity) {
            this.label = label;
            this.activity = activity;
        }
    }
}
